<?php
/**
 * 微校云主界面模型
 * Author: 孙武 QQ:1228746736
 * Date: 2017/11/1
 * Time: 10:37
 */

namespace Home\Model;
class UserModel extends \Think\Model
{

    /**
     * 根据id获取用户信息
     * @param $userId
     */
    public function getUserInfoById($userId)
    {

        $map=array('usr_id'=>$userId);
        $res=$this->find($userId);
        return $res;
    }


    public function getHadInvitePerson()
    {
        $usrId=session('userId');
        $sql="select count(share_id) as total from bus_user where share_id=$usrId";
        $res=D()->query($sql);
        return $res[0]['total'];
    }

    public function getHadBuyTime()
    {
        $usrId=session('userId');
        $sql="select count(user_id) as total from bus_order where user_id=$usrId";
        $res=D()->query($sql);
        return $res[0]['total'];
    }

    public function getJoinTime()
    {
        $usrId=session('userId');
        $sql="select usr_create_time as total from bus_user where usr_id=$usrId";
        $res=D()->query($sql);
        return $res[0]['total'];
    }
}